﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate.Tool.hbm2ddl;

namespace PhotoBook.Test
{
    [TestClass()]
    public class TestBase
    {

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestInitialize()]
        public void Preparar_Banco_De_Dados()
        {
            string copiarBancoPara = System.IO.Path.Combine(testContextInstance.TestDeploymentDir, "BookDataBase.sdf");
            string copiarBancoDe = System.IO.Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetParent(testContextInstance.TestDir).FullName).FullName, "PhotoBook.Model\\BookDataBase.sdf");
            if (!System.IO.File.Exists(copiarBancoPara))
            {
                System.IO.File.Copy(copiarBancoDe, copiarBancoPara);
                var config = new NHibernate.Cfg.Configuration();
                config.Configure(typeof(PhotoBook.Model.Entities.Album).Assembly, "PhotoBook.Model.Hibernate.cfg.xml");
                config.AddAssembly(typeof(PhotoBook.Model.Entities.Album).Assembly);
                new SchemaExport(config).Execute(false, true, false);
            }
        }
    }
}
